import { del, get, post, put } from "@/utils/request";
import {
  type DetailResult,
  type AddParams,
  type ListData,
  type ListParams,
  type ListResult,
  type DrugsPlansRes,
  type AddPlansParams,
  type UpdateEndDateParams,
  type DrugsPlansListData,
} from "./type";

export const getDrugsList = (data: ListParams) => {
  return get<ListParams, ListResult>("/api/drugs/list", data);
};

//添加
export const addDrugs = (data: AddParams) => {
  return post<AddParams, ListData>("/api/drugs/add", data);
};

//获取老人存药列表
export const getDrugsListForElderly = (id: number) => {
  return get<null, DetailResult>(`/api/drugs/listForElderly/${id}`);
};

//获取单条存药信息
export const getDrugsDetail = (id: number) => {
  return get<null, ListData>(`/api/drugs/get/${id}`);
};

//修改存药信息
export const updateDrugs = (data: AddParams) => {
  return put<AddParams, ListData>("/api/drugs/update", data);
};

//删除存药信息
export const delDrugs = (id: number) => {
  return del<null, null>(`/api/drugs/delete/${id}`);
};

//获取老人用药计划列表
export const getDrugsListForPlan = (id: number) => {
  return get<null, DrugsPlansRes>(`/api/drugs/listForPlan/${id}`);
};

//用药计划添加
export const addDrugPlan = (data: AddPlansParams) => {
  return post<AddPlansParams, AddPlansParams>("/api/drugPlan/add", data);
};

//停止用药
export const UpdateEndDate = (data: UpdateEndDateParams) => {
  return put<UpdateEndDateParams, DrugsPlansListData>("/api/drugPlan/updateEndDate", data);
};
